<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>工作台
            <small>地址管理</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>工作台</el-breadcrumb-item>
            <el-breadcrumb-item>地址管理</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="boxMain">
                <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
                    <template>
                        <el-tabs v-model="activeName" type="card" @tab-click="handleSelect">
                            <el-tab-pane label="分布图" name="first">
                                <el-container>
                                    <iframe name="right" class="el-main" src="map_distribution.html" width="100%"
                                            height="580px" frameborder="0"></iframe>
                                </el-container>
                            </el-tab-pane>
                            <el-tab-pane label="详细信息" name="second">
                                <div class="filter-container">
                                    <el-input placeholder="公司地址" v-model="pagination.queryString" style="width: 200px;"
                                              class="filter-item"></el-input>
                                    <el-button @click="findPage()" class="dalfBut">查询</el-button>
                                </div>
                                <el-table size="small" current-row-key="id" :data="dataList" stripe
                                          highlight-current-row>
                                    <el-table-column type="index" align="center" label="序号"></el-table-column>
                                    <el-table-column prop="address" label="公司地址" align="center"></el-table-column>
                                    <el-table-column prop="longitude" label="所在经度" align="center"></el-table-column>
                                    <el-table-column prop="latitude" label="所在纬度" align="center"></el-table-column>
                                    <el-table-column label="操作" align="center">
                                        <template slot-scope="scope">
                                            <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除
                                            </el-button>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <div class="pagination-container">
                                    <el-pagination
                                            class="pagiantion"
                                            @current-change="handleCurrentChange"
                                            :current-page="pagination.currentPage"
                                            :page-size="pagination.pageSize"
                                            layout="total, prev, pager, next, jumper"
                                            :total="pagination.total">
                                    </el-pagination>
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="添加公司地址" name="third">
                                <el-container>
                                    <iframe name="right" class="el-main" src="add_address.html" width="100%"
                                            height="580px"
                                            frameborder="0"></iframe>
                                </el-container>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                </el-menu>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    var vue = new Vue({
        el: '#app',
        data: {
            activeName: 'first',//添加
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize: 10,//每页显示的记录数
                total: 0,//总记录数
                queryString: null//查询条件
            },
            dataList: [],//当前页要展示的分页列表数据
        },

        methods: {
            handleSelect(tab,event){
               if (this.activeName=="first") {
                   window.location.href="./address.html";
               }else if(this.activeName=="second"){
                   this.findPage();
               }
            },
            //分页查询
            findPage() {
                //添加分页参数
                var param = {
                    currentPage: this.pagination.currentPage,//当前页码
                    pageSize: this.pagination.pageSize,//每页显示的记录数
                    queryString: this.pagination.queryString//查询条件
                };
                //发送ajax请求
                axios.post("/map/findPage.do", param).then((response) => {
                        this.dataList = response.data.rows;
                        this.pagination.total = response.data.total;
                })
            },

            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;//当前页码
                this.findPage();
            }
            ,
            // 删除
            handleDelete(row) {
                this.$confirm("你确定要删除吗?", "提示", {type: "waring"}).then(() => {
                    //当点击确认时执行
                    // 发送ajax请求
                    axios.post("/map/delete.do", {"address": row.address}).then((reponse) => {
                        if (reponse.data.flag) {
                            //删除成功
                            this.$message({
                                message: reponse.data.message,
                                type: "success"
                            })
                        } else {
                            //删除失败
                            this.$message.error(reponse.data.message)
                        }
                        //进行分页查询
                        this.findPage();
                    }).catch((r) => {
                        this.showMessage(r);
                    });
                })
            }
            ,
            showMessage(r) {
                if (r == 'Error: Request failed with status code 403') {
                    //权限不足
                    this.$message.error('无访问权限');
                    return;
                } else {
                    this.$message.error('未知错误');
                    return;
                }
            }
        }
    })
</script>
</html>








